package com.ghn.cocknovel.ui.activity.work.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.example.basemodel.base.BaseViewModel
import com.ghn.cocknovel.net.DataService
import com.kt.NetworkModel.bean.ResultListBean
import com.kt.NetworkModel.bean.SqueryPassengerBySiteBean
import com.kt.NetworkModel.bean.ToDayWorkTaskBean
import com.kt.NetworkModel.net.CallBack
import com.kt.NetworkModel.net.RxUtils

/**
 *@author: Administrator
 *2023/10/15
 *desc:
 */
class WorkTasksViewModel(application: Application) : BaseViewModel(application) {
    var currentPage = 1
    val mToDayWorkTaskBeanLiveData = MutableLiveData<ResultListBean<ToDayWorkTaskBean>>()
    val msqueryPassengerBySite= MutableLiveData<SqueryPassengerBySiteBean>()

    fun driverQueryTransitSchedulePlanListNet(scheduleDate: String="") {
        DataService.driverQueryTransitSchedulePlanList(currentPage, scheduleDate).compose(RxUtils.mainSync())
            .subscribe(object : CallBack<ResultListBean<ToDayWorkTaskBean>>() {
                override fun onResult(result: ResultListBean<ToDayWorkTaskBean>?) {
                    result?.also {
                        mToDayWorkTaskBeanLiveData.value = it
                    }
                }
            })
    }
    fun squeryPassengerBySite(id:String) {
        DataService.squeryPassengerBySite(id).compose(RxUtils.mainSync())
            .subscribe(object : CallBack<SqueryPassengerBySiteBean>() {
                override fun onResult(result: SqueryPassengerBySiteBean?) {
                    result?.also {
                        msqueryPassengerBySite.value = it
                    }
                }
            })
    }

}